/*大文件传输测试，给服务器上传一个大文件，服务器将文件保存下来，观察处理结果
预期效果：上传的文件，和服务器保存的文件一致*/
#include "../include/server.hpp"
#include "../include/http.hpp"
#include <unistd.h>
#include <cassert>
#include <cstdlib>
#include <cstring>

int main()
{
    Muduo::Socket cli_sock;
    cli_sock.CreateClientSocket(8888, "127.0.0.1");
    std::string req = "PUT /1234.txt HTTP/1.1\r\nConnection: keep-alive\r\n";
    std::string body;
    Muduo::Util::ReadFile("../src/hello.txt", &body);
    req += "Content-Length: " + std::to_string(body.size()) + "\r\n\r\n";
    int ret = cli_sock.Send((void*)req.c_str(), req.size());
    ret = cli_sock.Send((void*)body.c_str(), body.size());
    if(ret < 0){
        perror("出错了\n");
    }
    char buf[1024] = {0};
    assert(cli_sock.Recv(buf, 1023));
    LOGDEBUG("[%s]", buf);
    sleep(2);
    cli_sock.Close();
    return 0;
}